@import '../../style/themes/default';
@import '../../style/mixins/index';

@notification-prefix-cls: ~'@{c7n-prefix}-notification';
@notification-width: 3.84rem;
@notification-padding-vertical: 0.16rem;
@notification-padding-horizontal: 0.24rem;
@notification-padding: @notification-padding-vertical @notification-padding-horizontal;
@notification-margin-bottom: 0.16rem;

.@{notification-prefix-cls} {
  .reset-component;

  position: fixed;
  z-index: @zindex-notification;
  width: @notification-width;
  max-width: ~'calc(100vw - .32rem)';
  margin-right: 0.24rem;

  &-topLeft,
  &-bottomLeft {
    margin-right: 0;
    margin-left: 0.24rem;

    .@{notification-prefix-cls}-fade-enter.@{notification-prefix-cls}-fade-enter-active,
    .@{notification-prefix-cls}-fade-appear.@{notification-prefix-cls}-fade-appear-active {
      animation-name: NotificationLeftFadeIn;
    }
  }

  &-notice {
    position: relative;
    margin-bottom: @notification-margin-bottom;
    padding: @notification-padding;
    overflow: hidden;
    line-height: 1.5;
    background: @component-background;
    border-radius: @border-radius-base;
    box-shadow: @shadow-2;

    &-message {
      display: inline-block;
      margin-bottom: 0.08rem;
      color: @heading-color;
      font-size: @font-size-lg;
      line-height: 0.24rem;
      &-single-line-auto-margin {
        display: block;
        width: ~'calc(@{notification-width} - @{notification-padding-horizontal} * 2 - .24rem - .48rem - 100%)';
        max-width: 0.04rem;
        background-color: transparent;
        pointer-events: none;
        &::before {
          display: block;
          padding-bottom: 100%;
          content: '';
        }
      }
    }

    &-description {
      font-size: @font-size-base;
    }

    &-closable &-message {
      padding-right: 0.24rem;
    }

    &-with-icon &-message {
      margin-bottom: 0.04rem;
      margin-left: 0.48rem;
      font-size: @font-size-lg;
    }

    &-with-icon &-description {
      margin-left: 0.48rem;
      font-size: @font-size-base;
    }

    &-icon {
      position: absolute;
      margin-left: 0.04rem;
      font-size: 0.24rem;
      line-height: 0.24rem;

      &-success {
        color: @success-color;
      }
      &-info {
        color: @info-color;
      }
      &-warning {
        color: @warning-color;
      }
      &-error {
        color: @error-color;
      }
    }

    &-close-x::after {
      font-size: @font-size-base;
      font-family: anticon, sans-serif;
      cursor: pointer;
      content: '\e633';
    }

    &-close {
      position: absolute;
      top: 0.16rem;
      right: 0.22rem;
      color: @text-color-secondary;
      outline: none;

      a&:focus {
        text-decoration: none;
      }

      &:hover {
        color: #404040;
      }
    }

    &-btn {
      float: right;
      margin-top: 0.16rem;
    }
  }

  .notification-fade-effect {
    animation-duration: 0.24s;
    animation-timing-function: @ease-in-out;
    animation-fill-mode: both;
  }

  &-fade-enter,
  &-fade-appear {
    opacity: 0;
    .notification-fade-effect();
    animation-play-state: paused;
  }

  &-fade-leave {
    .notification-fade-effect();
    animation-duration: 0.2s;
    animation-play-state: paused;
  }

  &-fade-enter&-fade-enter-active,
  &-fade-appear&-fade-appear-active {
    animation-name: NotificationFadeIn;
    animation-play-state: running;
  }

  &-fade-leave&-fade-leave-active {
    animation-name: NotificationFadeOut;
    animation-play-state: running;
  }
}

@keyframes NotificationFadeIn {
  0% {
    left: @notification-width;
    opacity: 0;
  }
  100% {
    left: 0;
    opacity: 1;
  }
}

@keyframes NotificationLeftFadeIn {
  0% {
    right: @notification-width;
    opacity: 0;
  }
  100% {
    right: 0;
    opacity: 1;
  }
}

@keyframes NotificationFadeOut {
  0% {
    max-height: 1.5rem;
    margin-bottom: @notification-margin-bottom;
    padding-top: @notification-padding;
    padding-bottom: @notification-padding;
    opacity: 1;
  }
  100% {
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
  }
}
